<template>
  <a-layout-content style="margin: 0 16px">
    <a-button type="primary" @click="goback" style="margin-bottom: 20px"
      >返回</a-button
    >
   
      <div :style="{ padding: '24px', background: '#fff', minHeight: '30px' }">
        <p class="titleMess">基础信息</p>
        <a-divider />
        <a-form
          ref="formRef"
          :model="addTaskForm"
        >
           <a-form-item ref="taskCode" label="任务编号"  :required="true">
            <span>{{addTaskForm.taskCode}}</span>
            </a-select>
          </a-form-item>
          <a-form-item ref="taskSceneId" label="业务场景"  :required="true">
            <a-select
              v-model:value="addTaskForm.taskSceneId"
              placeholder="请选择任务场景"
              @change="selectScene"
              :options="sceneOptions"
            />
            </a-select>
          </a-form-item>
          <a-form-item ref="taskObject" label="任务级别" name="taskObject"  :required="true">
            <a-select
              v-model:value="addTaskForm.taskObject"
              :options="taskObjectData"
              @change="changeTaskObject"
              placeholder="请选择任务级别"
            />
            <span class="tishi"
              ><br />门店任务:发布到门店所有导购,任意1个导购完成,其他导购任务也完成;导购任务:发布到设置的导购,需每个导购均需自行完成;自动任务:无需导购执行,系统直接将任务作用于目标会员</span
            >
          </a-form-item>
          <a-form-item ref="taskTitle" label="任务名称" name="taskTitle" :required="true">
            <a-input
              placeholder="填写名称，最多40字"
              v-model:value="addTaskForm.taskTitle"
              autoComplete="off"
              :maxLength="40"
              
            />
            <span class="tishi">任务的通用公开名称,供导购端展示使用</span>
          </a-form-item>
          <a-form-item ref="taskAlias" label="任务别名" name="taskAlias" class="ml">
            <a-input
              placeholder="填写名称，最多40字"
              v-model:value="addTaskForm.taskAlias"
              autoComplete="off"
              :maxLength="40"
            />
            <span class="tishi">别名供公司内部使用</span>
          </a-form-item>
          <a-form-item
            ref="taskDescription"
            label="任务说明"
            name="taskDescription"
            :required="true"
          >
            <a-textarea
              v-model:value="addTaskForm.taskDescription"
              placeholder="填写说明，最多400字"
              style="min-height: 180px"
              auto-size
              :maxLength="400"
            />
          </a-form-item>
          <a-form-item ref="execType" label="执行时效" name="execType" :required="true">
            <a-select
              v-model:value="addTaskForm.execType"
              @change="changeexecType"
              :options="execTypeData"
              :value="execTypeData.value"
              placeholder="请选择执行时效"
            >
            </a-select>
          </a-form-item>
          <!-- 选择单次 -->
          <div v-if="addTaskForm.execType===2">
            <a-form-item ref="effectDate" label="开始时间" name="effectDate" :required="true">
              <a-date-picker
                show-time
                placeholder="请选择时间"
                v-model:value="addTaskForm.effectDate"
                :format="dateFormat"
                :value-format="dateFormat"
              />
            </a-form-item>
            <a-form-item ref="expireTime" label="有效期" name="expireTime" class="ml">
              <a-input-number
                style="width: 200px"
                id="inputNumber"
                v-model:value="addTaskForm.expireTime"
                :min="1"
                :max="30"
                :controls="false"
                placeholder="填写数字，并选择单位"
              />
              <a-select
                v-model:value="addTaskForm.expireType"
                :options="expireTypeData"
                :value="expireTypeData.value"
                placeholder="请选择时间单位"
                style="margin-left: 10px"
                name="expireType"
              >
              </a-select>
              <span class="tishi">不填写时间单位默认为天</span>
            </a-form-item>
            <a-form-item label="发布时间" ref="publishDate" name="publishDate" class="ml">
              <a-date-picker
                show-time
                placeholder="请选择时间"
                v-model:value="addTaskForm.publishDate"
                :format="dateFormat"
                :value-format="dateFormat"
              />
              <span class="tishi"
                >导购/门店任务下发时间，不填写表示立即生效</span
              >
            </a-form-item>
          </div>
          <!-- 定时循环 -->
          <div v-if="addTaskForm.execType===1" >
            <a-form-item ref="cycleType" label="执行周期" name="cycleType" :required="true">
              <a-select
                v-model:value="addTaskForm.cycleType"
                @change="changecycleType"
                :options="cycleTypeData"
                :value="cycleTypeData.value"
                placeholder="请选择时间单位"
              >
              </a-select>
            </a-form-item>
            <!-- 每周执行 -->
            <!-- @change="handleChange" -->
            <a-form-item
              ref="execWeek"
              label="每周执行"
              name="execWeek"
              v-if="addTaskForm.cycleType===2"
              :required="true"
            >
              <a-select
                v-model:value="addTaskForm.execWeek"
                :options="execWeekData"
                :value="execWeekData.value"
                placeholder="请选择时间单位"
              />
            </a-form-item>
            <!-- 每月执行 -->
            <!-- @change="handleChange" -->
            <a-form-item
              ref="execDay"
              label="每月执行"
              name="execDay"
              v-if="addTaskForm.cycleType===3"
              :required="true"
            >
              <a-select
                v-model:value="addTaskForm.execDay"
                :options="monthDataForm"
                :value="monthDataForm.value"
                placeholder="请选择时间单位"
              />
            </a-form-item>
            <!-- @change="handleChange" -->
            <a-form-item ref="execTime" label="开始时间" name="execTime" :required="true">
           <a-time-picker
                show-time
                placeholder="请选择时间"
                v-model:value="addTaskForm.execTime"
                :format="dayFormat"
                :value-format="dayFormat"
              />
              </a-select>
            </a-form-item>
            <a-form-item ref="expireTime" label="有效期" name="expireTime" class="ml" :required="true">
              <a-input-number
                style="width: 200px"
                id="inputNumber"
                v-model:value="addTaskForm.expireTime"
                :min="1"
                :max="10000"
                :controls="false"
                placeholder="填写数字，并选择单位"
              />
              <!-- @change="handleChange" -->
              <a-select
                v-model:value="addTaskForm.expireType"
                :options="expireTypeData"
                :value="expireTypeData.value"
                placeholder="请选择时间单位"
                style="margin-left: 10px"
              >
              </a-select>
              <span class="tishi">不填写时间单位默认为天</span>
              </a-form-item>
            </div>
            <a-form-item
            ref="taskType"
            label="任务类型"
            name="taskType"
            v-if="addTaskForm.cycleType=== 4"
            :required="true"
          >
            <a-select
              v-model:value="addTaskForm.taskType"
              :options="messageTaskTypeData"
              @change="changetaskType"
              placeholder="请选择任务类型"
              
            >
            </a-select>
          </a-form-item>
           <!-- 消息模板 -->
          <a-form-item
            label="任务路径:"
            name="messageId"
            v-if="messIdVisible&&addTaskForm.cycleType=== 4"
            :keys="3"
            :required="true"
          >
            <MessageDioloag @chooseData="chooseTemplateId" />
          </a-form-item>
          

          <!-- 条件触点 -->
          <div v-show="strikeVisible" :keys="3">
            <a-form-item ref="contact" label="触点" name="contact" class="ml">
              <!-- @change="handleChange" -->
              <a-select
                v-model:value="addTaskForm.contact"
                :options="contactData"
                :value="contactData.value"
                placeholder="请选择时间单位"
              />
            </a-form-item>
            <a-form-item ref="expireTime" label="有效期" name="expireTime" :required="true">
              <a-input-number
                style="width: 200px"
                id="inputNumber"
                v-model:value="addTaskForm.expireTime"
                :min="1"
                :max="10"
                :controls="false"
                placeholder="填写数字，并选择单位"
              />
              <!-- @change="handleChange" -->
              <a-select
                v-model:value="addTaskForm.expireType"
                :options="expireTypeData"
                :value="expireTypeData.value"
                placeholder="请选择时间单位"
                style="margin-left: 10px"
              >
              </a-select>
            </a-form-item>
          </div>
          <a-form-item ref="endProcess" label="到期是否执行" name="endProcess" :required="true">
            <a-radio-group
              v-model:value="addTaskForm.endProcess"
              :options="endProcessDate"
            />
          </a-form-item>
          <!-- 门店任务或导购任务 -->
          <a-form-item
            ref="taskType"
            label="任务类型"
            name="taskType"
            v-if="addTaskForm.taskObject === 1&&addTaskForm.cycleType!== 4"
            :required="true"
          >
            <a-select
              v-model:value="addTaskForm.taskType"
              label-in-val
              :options="taskTypeData"
              :value="taskTypeData.value"
              @change="changetaskType"
              placeholder="请选择任务类型"
             
            >
            </a-select>
          </a-form-item>
          <a-form-item
            ref="taskType"
            label="任务类型"
            name="taskType"
            v-if="addTaskForm.taskObject === 2&&addTaskForm.cycleType!== 4"
            class="ml"
          >
            <a-select
              v-model:value="addTaskForm.taskType"
              label-in-val
              :options="storeTaskTypeData"
              :value="storeTaskTypeData.value"
              @change="changetaskType"
              placeholder="请选择任务类型"
              
            >
            </a-select>
          </a-form-item>
          <!-- 自动任务 -->
          <a-form-item
            ref="taskType"
            label="任务类型"
            name="taskType"
            v-if="addTaskForm.taskObject === 3&&addTaskForm.cycleType!== 4"
            :required="true"
          >
            <a-select
              v-model:value="addTaskForm.taskType"
              :options="autoTaskTypeData"
              @change="changetaskType"
              :value="autoTaskTypeData.value"
              placeholder="请选择任务类型"
              
            >
            </a-select>
          </a-form-item>
          <a-form-item
            label="联系触达"
            name="custConnectType"
            v-if="callVisible"
            :keys="1"
            :required="true"
          >
            <!-- 联系触达 -->
            <a-checkbox-group
              v-model:value="addTaskForm.custConnectType"
              :options="custConnectTypeData"
            />
          </a-form-item>
          <!-- 微信转发 -->
          <a-form-item
            label="微信转发方式"
            name="wechatType"
            v-if="wechatVisible"
            :keys="2"
            :required="true"
          >
            <a-radio-group
              v-model:value="addTaskForm.wechatType"
              :options="wechatTypeData"
              @change="wechatTypeDataClick"
            />
            <!-- @change="handleChange" -->
            <a-select
              v-if="rangeVisible"
              v-model:value="addTaskForm.visibleType"
              @change="changeRange"
              :value="rangeData.value"
              :options="rangeData"
              placeholder="请选择可见范围"
              style="margin-left: 10px"
            />
          </a-form-item>
          <!-- 消息模板 -->
          <a-form-item
            label="任务路径:"
            name="messageId"
            v-if="messIdVisible"
            :keys="3"
            :required="true"
          >
            <MessageDioloag @chooseData="chooseTemplateId" :templateIdList="templateIdList"/>
          </a-form-item>
          <!-- 优惠券发放 -->

          <a-form-item
            label="任务路径"
            name="ticketId"
            v-if="onSaleVisible"
            :keys="4"
            :required="true"
          >
            <DiscountDioloag @chooseData="chooseTicketList"  :ticketIdList="ticketIdList"/>
          </a-form-item>
          <!-- 公众号推文 -->
          <a-form-item
            label="任务路径"
            name="articleId"
            v-if="officialAccountsVisible"
            :keys="5"
            :required="true"
          >
            <WeChatDioloag @chooseData="choosegraphicList" :graphicList="graphicList"/>
          </a-form-item>
          <a-form-item
            v-if="ifAuto"
            ref="feedbackType"
            label="反馈方式"
            name="feedbackType"
             :required="true"
          >
            <!-- @change="handleChange" -->
            <a-select
              v-model:value="addTaskForm.feedbackType"
              @change="changeFeedBack"
             
              :options="feedbackTypeData"
              placeholder="请选择反馈方式"
            />
          </a-form-item>
          <a-form-item
            label="执行导购"
            name="guideType"
            v-if="addTaskForm.taskObject === 1 &&addTaskForm.cycleType!== 4"
            class="ml"
            :require="true"
          >
            <a-select
              v-model:value="addTaskForm.guideType"
              @change="changeGuide"
              placeholder="请选择"
              :options="guideData"
              :disabled="isDisabled"
            />
          </a-form-item>

          <a-form-item
            label="执行导购"
            name="guideType"
            v-if="addTaskForm.taskObject === 2&&addTaskForm.cycleType!== 4"
            :required="true"
          >
            <a-select
              v-model:value="addTaskForm.guideType"
              @change="changeGuide"
              placeholder="请选择"
              :options="storeGuideData"
              :disabled="isDisabled"
            />
          </a-form-item>

          <a-form-item
            label="指定导购"
            v-if="appointGuideVisible"
            :keys="1"
            name="dealerType"
             :required="true"
          >
            <a-select
              v-model:value="addTaskForm.dealerType"
              :options="matchingData"
              @change="scopeGuide"
              placeholder="请选择范围"
            />
            <UploadGuide @chooseData="chooseGuideExcel" v-if="guideExcel" :guideInfo="guideInfo"/>
          </a-form-item>
          <!-- 指定门店对应导购 -->
          <div v-if="appointshopGuideVisible" :keys="2">
            <a-form-item label="指定门店" name="storeType"  :required="true">
              <a-select
                @change="scopeShop"
                v-model:value="addTaskForm.storeType"
                :options="matchingShopData"
                placeholder="请选择范围"
              />
              <!-- 批量导入门店Excel -->
              <UploadStore @chooseData="choosexcelData" v-if="shopExcel" :storeInfo="storeInfo"/>
            </a-form-item>
          </div>
          <!-- 指定会员对应导购 -->
          <div v-show="appointvipGuideVisible&&addTaskForm.cycleType!== 4" :keys="3">
            <a-form-item label="目标会员" ref="custPack" name="custPack"  :required="true">
              <a-select
                v-model:value="addTaskForm.peopleType"
                :options="aimVip"
                @change="onChooseVip"
                placeholder="请选择目标会员类型"
               
              />
            </a-form-item>

            <a-form-item label="添加人群包" ref="custPacks" name="custPacks"  :required="true">
              <PersonDioloag
                @chooseData="chooseCustList"
                :peopleType="peopleType"
                :custList="custList"
              />
            </a-form-item>
          </div>

          <UplpadEnclosure  @chooseData="getUploadData"  :mediaDetail="mediaDetail"  v-if="addTaskForm.taskObject!==3" ref="uploadEnclosure"/>
        </a-form>
          <!-- <div>
          <a-button class="addBtn" @click="addBtn(0)" type="primary"
            >保存为草稿</a-button
          >
          <a-button
            class="addBtn"
            style="margin-left: 20px"
            @click="addBtn(1)"
            type="primary"
            >发布</a-button
          >
        </div> -->
      </div>
     
  </a-layout-content>
</template>

<script>
import axios from 'axios'
import { addTask, getTaskInfo, updateTaskInfo, uploadTaskMedia } from '@/api/task/taskrelese'
import { getOpenScene } from '@/api/task/taskscene'
import { monthData, timeData } from '@/assets/taskdata'

import api from '@/utils/taskapi'
import DiscountDioloag from '@/components/task/taskDioloag/DiscountDioloag'
import MessageDioloag from '@/components/task/taskDioloag/MessageDioloag'
import WeChatDioloag from '@/components/task/taskDioloag/WeChatDioloag'
import PersonDioloag from '@/components/task/taskDioloag/PersonDioloag'
import UploadGuide from '@/components/task/uploadGuide/index.vue' //解析导购excel
import UploadStore from '@/components/task/uploadStore/index.vue' //解析门店excel
import UplpadEnclosure from '@/components/task/uploadEnclosure/index.vue' //上传材料
export default {
  name: 'relesework',
  components: {
    DiscountDioloag,
    MessageDioloag,
    WeChatDioloag,
    PersonDioloag,
    UploadGuide,
    UploadStore,
    UplpadEnclosure
  },
  data() {
    return {
      editId: '',
      taskId: '',
      ifDraft: '',
      dateFormat: 'YYYY-MM-DD HH:mm:ss',
      dayFormat: 'HH:mm',
      spinning: false,
      sceneOptions: [],
      uploadForm: [],
      uploadUrl: 'https://jic.jnby.com/activity/market-act/common/upload/multipart',
      spinning: false,
      timeDataForm: timeData,
      monthDataForm: monthData,
      addTaskForm: {},
      allData: [],
      aimVip: [
        { label: '实时人群包', value: 1 },
        { label: '非实时人群包', value: 2 }
      ],
      taskObjectData: [
        { label: '导购任务', value: 1 },
        { label: '门店任务', value: 2 },
        { label: '自动任务', value: 3 }
      ],
      execTypeData: [
        { label: '定时循环', value: 1 },
        { label: '单次', value: 2 }
        // {label: '条件触点', value:3}
      ],
      cycleTypeData: [
        { label: '每天执行', value: 1 },
        { label: '每周执行', value: 2 },
        { label: '每月执行', value: 3 }
      ],
      execWeekData: [
        { label: '周一', value: 1 },
        { label: '周二', value: 2 },
        { label: '周三', value: 3 },
        { label: '周四', value: 4 },
        { label: '周五', value: 5 },
        { label: '周六', value: 6 },
        { label: '周日', value: 7 }
      ],
      expireTypeData: [
        { label: '小时', value: 0 },
        { label: '天', value: 1 }
      ],
      contactData: [
        { label: '触点一', value: 1 },
        { label: '触点二', value: 2 }
      ],
      endProcessDate: [
        { label: '是', value: 1 },
        { label: '否', value: 2 }
      ],
      taskTypeData: [
        { label: '联系触达', value: 1 },
        { label: '微信转发', value: 2 },
        { label: '自定义任务', value: 6 },
        { label: '添加会员微信', value: 7 }
      ],
      storeTaskTypeData: [{ label: '自定义任务', value: 6 }],
      autoTaskTypeData: [
        { label: '消息模板', value: 3 },
        { label: '优惠券发放', value: 4 },
        { label: '公众号推文', value: 5 }
      ],
      messageTaskTypeData: [{ label: '消息模板', value: 3 }],
      targetVipData: [{ label: '雅通人群包', value: 1 }],
      custConnectTypeData: [
        { label: '电话', value: 1 },
        { label: '短信', value: 2 },
        { label: '微信私聊', value: 3 }
      ],
      wechatTypeData: [
        { label: '企微批量发送', value: 1 },
        { label: '企微分享', value: 3 },
        { label: '企微朋友圈', value: 2 }
      ],
      rangeData: [
        { label: '全部好友', value: 1 },
        { label: '指定目标好友', value: 2 }
      ],
      guideData: [
        { label: '指定导购', value: 1 },
        { label: '指定门店对应导购', value: 2 },
        { label: '指定会员对应导购', value: 3 }
      ],
      storeGuideData: [
        { label: '指定导购', value: 1 },
        { label: '指定门店对应导购', value: 2 },
        { label: '指定会员对应导购', value: 3 }
      ],
      matchingData: [
        { label: '全部导购', value: 0 },
        { label: '指定导购', value: 1 }
      ],
      matchingShopData: [
        { label: '全部门店', value: 0 },
        { label: '指定门店', value: 1 }
      ],
      feedbackTypeData: [
        { label: '统一反馈', value: 0 },
        { label: '按会员反馈', value: 1 }
      ],
      mediaTypeData: [
        { label: '无', value: 0 },
        { label: '文本', value: 1 },
        { label: '图片+文本', value: 2 },
        { label: '视频+文本', value: 3 },
        { label: '链接+文本', value: 4 },
        { label: '小程序链接+文本', value: 5 }
      ],

      taskInfo: [],
      fileList: [],
      affixFileList: [],
      onceVisible: false,
      circulationVisible: false,
      strikeVisible: false,
      callVisible: false,
      wechatVisible: false,
      messIdVisible: false, //消息模板
      onSaleVisible: false, //优惠券发放
      officialAccountsVisible: false, //公众号推文
      outlineVisible: false, //自定义任务
      guideTypeVisible: true, //执行导购
      appointGuideVisible: false,
      appointshopGuideVisible: false,
      appointvipGuideVisible: false,
      daysVisible: false,
      weeksVisible: false,
      monthsVisible: false,
      linkVisible: false,
      imgVisible: false,
      movieVisible: false,
      programVisible: false,
      textVisible: false,
      guideExcel: false, //指定导购excel上传按钮
      shopExcel: false, //指定门店excel上传按钮
      // taskId:''
      // taskDefineId:'',
      notAutoTaskVisible: false, //门店任务导购任务
      autoTaskVisible: false, //自动任务
      targetVipVisible: false, //目标会员
      ifAuto: false, //判断是否为自动任务 true则显示反馈方式，false则隐藏
      rangeVisible: false, //选择企业微信朋友圈后的可见范围选择下拉框
      vipList: [],
      isDisabled: false,
      monidata: ['11', '22', '33', '44'],
      videoTime: '',
      peopleType: 1,
      ticketIdList: [],
      templateIdList: [],
      graphicList: [],
      custList: [],
      excelData: '',
      enclosure: {},
      mediaDetail: {},
      keyVal: '',
      addTaskForm: {
        custConnectType: [],
        wechatType: '',
        feedbackType: '',
        guideType: '',
        visibleType: '',
        taskType: '',
        expireTime: '',
        endProcess: '',
        taskAlias: '',
        expireType: '',
        custPack: ''
      },
      storeCodes: '',
      storeInfo: [],
      guideInfo: [],
      creator: ''
    }
  },
  created() {
    this.getDatas()
    this.getScene()
    this.creator = JSON.parse(localStorage.getItem('pro__Login_Userinfo')).value.realname
  },

  methods: {
    getDatas() {
      this.fileList = []

      // 有id就是编辑
      let id = this.$route.query.id
      console.log(id)
      if (id) {
        this.editId = id
        getTaskInfo(
          {
            id
          },
          res => {
            console.log('res', res.data)
            for (let mess in res.data) {
              if (res.data[mess] === -1) {
                res.data[mess] = null
              }
            }
            this.addTaskForm = res.data
            // 获取门店信息
            // 获取场景
            // this.addTaskForm.execType=res.data.
            this.addTaskForm.taskSceneId = res.data.taskSceneId + ''
            this.addTaskForm.endProcess = Number(res.data.endProcess)
            if (res.data.storeCodes) {
              this.excelData = res.data.storeCodes
            }
            if (res.data.dealerIds) {
              this.excelData = res.data.dealerIds
            }
            console.log(res.data.storeCodes, '00000')
            if (res.data.storeCodes) {
              let datas = JSON.parse(res.data.storeCodes)
              datas.forEach((item, index) => {
                this.storeInfo.push({
                  key: index,
                  code: item
                })
              })
            } else if (res.data.dealerIds) {
              let datas = JSON.parse(res.data.dealerIds)
              datas.forEach((item, index) => {
                this.guideInfo.push({
                  key: index,
                  code: item
                })
              })
            }

            if (res.data.mediaDetail) {
              this.mediaDetail = res.data.mediaDetail
              this.enclosure = res.data.mediaDetail
              console.log('父组件mediaDetail', this.mediaDetail)
              this.$refs.uploadEnclosure.setMediaData(this.mediaDetail)
            }
            //  获取指定导购
            if (res.data.guideType === 1) {
              this.addTaskForm.guideType = res.data.guideType
              this.appointGuideVisible = true
              this.guideExcel = true
            }
            //
            if (res.data.storeType === 1) {
              this.appointshopGuideVisible = true
              this.shopExcel = true
            }
            if (res.data.guideType === 3) {
              this.appointvipGuideVisible = true
              this.peopleType = res.data.peopleType
              this.custList = JSON.parse(res.data.custPack) //人群包
            }
            if (res.data.custPack) {
              this.peopleType = res.data.peopleType
              this.custList = JSON.parse(res.data.custPack) //人群包
              console.log(this.custList)
            } else {
              return
            }
            if (res.data.ticketId) {
              this.ticketIdList = JSON.parse(res.data.ticketId) //优惠券
            } else if (res.data.messageId) {
              this.templateIdList = JSON.parse(res.data.messageId) //消息模板
            } else if (res.data.articleId) {
              this.graphicList = JSON.parse(res.data.articleId) //公众号
            }
            console.log('ticketIdList getTaskInfo ', this.ticketIdList)
            this.ifDraft = res.data.publishStatus
            this.addTaskForm = res.data
            // this.addTaskForm.custPack = ''
            this.vipList = []
            let wechatType = Number(res.data.wechatType)
            if (wechatType === 2) {
              this.rangeVisible = false
            }
            let execType = this.addTaskForm.execType // 执行时效s
            // this.cleanExecType();
            if (execType === 2) {
              this.onceVisible = true
            } else if (execType === 1) {
              this.circulationVisible = true
            } else if (execType === 3) {
              this.strikeVisible = true
            } // 执行时效e
            // this.changeTaskObject()
            let taskObject = this.addTaskForm.taskObject
            console.log(taskObject)
            if (taskObject === 3) {
              this.autoTaskVisible = true
              this.targetVipVisible = true
              this.appointvipGuideVisible = true
            } else {
              this.notAutoTaskVisible = true
            }
            let taskType = this.addTaskForm.taskType // 任务类型s
            this.cleantaskType()
            if (taskType === 1) {
              this.callVisible = true
            } else if (taskType === 2) {
              this.wechatVisible = true
            } else if (taskType === 3) {
              this.messIdVisible = true
            } else if (taskType === 4) {
              this.onSaleVisible = true
            } else if (taskType === 5) {
              this.officialAccountsVisible = true
            } else if (taskType === 6) {
              this.outlineVisible = true
              this.ifAuto = true
            } // 任务类型e
            //执行周期
            let cycleType = this.addTaskForm.cycleType
            this.cleancycleType()
            if (cycleType === 1) {
              this.daysVisible = true
            } else if (cycleType === 2) {
              this.weeksVisible = true
            } else if (cycleType === 3) {
              this.monthsVisible = true
            }
            if (!res.data.custConnectType) {
              return
            } else {
              this.addTaskForm.custConnectType = JSON.parse(res.data.custConnectType)
            }
            this.addTaskForm.wechatType = Number(res.data.wechatType)
            // 目标会员
          }
        )
      }
    },

    goback() {
      this.$router.back()
    },

    onChooseVip(value) {
      this.peopleType = value
      console.log('peopleType', this.peopleType)
      this.custList = []
    },
    // 传递材料信息
    getUploadData(value) {
      this.enclosure = value
      console.log('uploadDatas after   ', value)
    },
    // 传递excel(导购)
    chooseGuideExcel(list) {
      this.excelData = list
      console.log('choose', this.excelData)
    },
    // 传递excel(门店)
    choosexcelData(list) {
      this.excelData = list
      console.log('choose', this.excelData)
    },
    // 传递优惠券
    chooseTicketList(list) {
      this.ticketIdList = list
      console.log('choose', list)
    },
    // 传递文章
    choosegraphicList(list) {
      this.graphicList = list
      console.log('choose', list)
    },
    // 传递模板
    chooseTemplateId(list) {
      this.templateIdList = list
      console.log('choose', list)
    },
    // 传递人群包
    chooseCustList(list) {
      this.custList = list
      console.log('choose', list)
    },
    changeWechat(e) {
      console.log(e)
    },
    selectScene(val, opt) {
      this.addTaskForm.taskSceneId = val
      this.addTaskForm.taskGroupId = opt.taskGroupId
    },

    changeTaskObject() {
      this.ifAuto = false
      if (this.addTaskForm.taskObject === 3) {
        this.appointvipGuideVisible = true
        this.vipList = []
        this.addTaskForm.custPack = ''
        this.autoTaskVisible = true
        // this.targetVipVisible = true
        this.notAutoTaskVisible = false
        this.addTaskForm.taskType = null
        this.addTaskForm.custConnectType = [] //清除联系触达内容
        this.addTaskForm.wechatType = '' //清除微信转发内容
        this.callVisible = false //隐藏联系触达
        this.wechatVisible = false //隐藏微信转发
        this.messIdVisible = false
        this.onSaleVisible = false
        this.officialAccountsVisible = false
        this.guideTypeVisible = false
        this.addTaskForm.guideType = null
        this.appointGuideVisible = false
        this.appointshopGuideVisible = false
        // this.appointvipGuideVisible = false
      } else {
        this.vipList = [] //人群包清空
        this.appointvipGuideVisible = false
        this.addTaskForm.custPack = '' //人群包清空
        this.guideTypeVisible = true
        this.autoTaskVisible = false
        // this.targetVipVisible = false
        this.notAutoTaskVisible = true
        this.addTaskForm.taskType = null
        this.addTaskForm.messageId = '' //清除消息模板内容
        this.messIdVisible = false //消息模板ID隐藏
        this.addTaskForm.ticketId = '' //清除优惠券发放内容
        this.onSaleVisible = false //优惠券发放ID隐藏
        this.addTaskForm.articleId = '' //清除公众号推文内容
        this.officialAccountsVisible = false //公众号推文ID隐藏
        this.callVisible = false //隐藏联系触达
        this.wechatVisible = false //隐藏微信转发
        this.addTaskForm.guideType = null
      }
    },
    wechatTypeDataClick() {
      if (this.addTaskForm.wechatType === 1) {
        this.isDisabled = true //执行导购选择框不可用
        this.addTaskForm.guideType = 3 //执行导购默认选择指定会员
        this.appointvipGuideVisible = true //人群包输入框显示
        this.appointGuideVisible = false //指定导购选择范围框隐藏
        this.appointshopGuideVisible = false //指定门店选择范围框隐藏
        this.rangeVisible = false //朋友圈可见范围下拉选择框隐藏
        this.mediaTypeData = [
          { label: '无', value: 0 },
          { label: '文本', value: 1 },
          { label: '图片+文本', value: 2 },
          { label: '视频+文本', value: 3 },
          { label: '链接+文本', value: 4 },
          { label: '小程序链接+文本', value: 5 }
        ]
        this.addTaskForm.visibleType = null
      } else if (this.addTaskForm.wechatType === 2) {
        this.isDisabled = false //执行导购选择框可用
        this.rangeVisible = true //朋友圈可见范围下拉选择框隐藏
        this.uploadForm.mediaType = null
        this.programVisible = false
        this.mediaTypeData = [
          { label: '无', value: 0 },
          { label: '文本', value: 1 },
          { label: '图片+文本', value: 2 },
          { label: '视频+文本', value: 3 },
          { label: '链接+文本', value: 4 }
        ]
      } else if (this.addTaskForm.wechatType === 3) {
        this.isDisabled = false //执行导购选择框可用
        this.rangeVisible = false //朋友圈可见范围下拉选择框隐藏
        this.mediaTypeData = [
          { label: '无', value: 0 },
          { label: '文本', value: 1 },
          { label: '图片+文本', value: 2 },
          { label: '视频+文本', value: 3 },
          { label: '链接+文本', value: 4 },
          { label: '小程序链接+文本', value: 5 }
        ]
        this.addTaskForm.visibleType = null
      }
    },
    getScene() {
      let data = {}
      getOpenScene(data, res => {
        console.log('sencen       ', res)
        this.sceneOptions = res.data
      })
    },
    //编辑
    addBtn(val) {
      let id = this.$route.query.id
      console.log('addBtn    before   ')
      if (!this.addTaskForm.taskSceneId) {
        this.$message.error('请选择场景!')
        return
      }
      if (!this.addTaskForm.taskObject) {
        this.$message.error('请选择任务级别!')
        return
      }
      if (!this.addTaskForm.taskTitle) {
        this.$message.error('请选择任务名称!')
        return
      }
      if (!this.addTaskForm.taskDescription) {
        this.$message.error('请填写任务描述!')
        return
      }
      if (!this.addTaskForm.taskType) {
        this.$message.error('请选择任务类型!')
        return
      }
      console.log('addBtn    start   ')
      let taskDefineId
      let data = {
        id: id,
        // taskGroupId: this.addTaskForm.taskGroupId, //分组id
        taskSceneId: this.addTaskForm.taskSceneId, //场景id
        taskObject: Number(this.addTaskForm.taskObject), //任务级别
        taskTitle: this.addTaskForm.taskTitle, //任务名称
        taskAlias: this.addTaskForm.taskAlias, //任务别名
        taskDescription: this.addTaskForm.taskDescription, //任务说明
        execType: Number(this.addTaskForm.execType), //执行时效 value
        endProcess: Number(this.addTaskForm.endProcess), //到期是否执行
        taskType: Number(this.addTaskForm.taskType), //任务类型
        creator: this.creator, //创建人
        // feedbackType:Number(this.addTaskForm.feedbackType), //反馈方式
        // guideType:Number(this.addTaskForm.guideType),
        publishStatus: val,
        peopleType: this.peopleType //选择人群包
      }
      if (this.addTaskForm.dealerType === 1) {
        // if(this.excelData){
        //   if(JSON.parse(this.excelData).length===0){
        //       this.$message.error('请上传Excel文件!')
        // return
        //   }
        // }
        if (this.excelData.length === 0) {
          this.$message.error('请上传Excel文件!')

          return
        }
        // 上传导购表
        data.dealerIds = this.excelData
      }
      if (this.addTaskForm.storeType === 1) {
        // if(this.excelData){
        //    if(JSON.parse(this.excelData).length===0){
        //         this.$message.error('请上传Excel文件!')
        //         return
        //   }
        // }

        if (this.excelData.length === 0) {
          this.$message.error('请上传Excel文件!')

          return
        }
        //  上传门店表
        data.storeCodes = this.excelData
      }

      if (this.addTaskForm.execType === 2) {
        data.effectDate = this.addTaskForm.effectDate //生效时间
        data.expireTime = Number(this.addTaskForm.expireTime) //有效期
        data.expireType = Number(this.addTaskForm.expireType) //有效期单位（小时/天）
        data.publishDate = this.addTaskForm.publishDate //发布时间
      } else if (this.addTaskForm.execType === 1) {
        if (this.addTaskForm.cycleType === 1) {
          data.cycleType = Number(this.addTaskForm.cycleType)
          data.execTime = this.addTaskForm.execTime
          data.effectDate = this.addTaskForm.effectDate
          data.expireTime = Number(this.addTaskForm.expireTime) //有效期
          data.expireType = Number(this.addTaskForm.expireType) //有效期单位（小时/天）
        } else if (this.addTaskForm.cycleType === 2) {
          data.cycleType = Number(this.addTaskForm.cycleType)
          data.execWeek = parseInt(this.addTaskForm.execWeek)
          data.execTime = this.addTaskForm.execTime
          data.expireTime = Number(this.addTaskForm.expireTime)
          data.expireType = Number(this.addTaskForm.expireType)
        } else if (this.addTaskForm.cycleType === 3) {
          data.cycleType = Number(this.addTaskForm.cycleType)
          data.execDay = parseInt(this.addTaskForm.execDay)
          data.execTime = this.addTaskForm.execTime
          data.expireTime = Number(this.addTaskForm.expireTime)
          data.expireType = Number(this.addTaskForm.expireType)
        }
      }
      if (this.addTaskForm.taskType === 1) {
        //联系触达
        // data.custConnectType = this.addTaskForm.custConnectType
        if (this.addTaskForm.custConnectType) {
          if (this.addTaskForm.custConnectType.length == 0) {
            this.$message.error('请选择联系触达方式')
            this.spinning = false
            return
          }
          data.custConnectType = JSON.stringify(this.addTaskForm.custConnectType)
        } else {
          this.$message.error('请选择联系触达方式')
          this.spinning = false
          return
        }
      } else if (this.addTaskForm.taskType === 2) {
        //微信转发
        if (this.addTaskForm.wechatType === 2) {
          data.wechatType = this.addTaskForm.wechatType
          if (!this.addTaskForm.visibleType) {
            this.addTaskForm.visibleType = 1
            data.visibleType = this.addTaskForm.visibleType
          } else {
            data.visibleType = this.addTaskForm.visibleType //企业微信朋友圈的可见范围
          }
        } else {
          data.wechatType = this.addTaskForm.wechatType
          // data.wechatType = JSON.stringify(this.addTaskForm.wechatType)
        }
      } else if (this.addTaskForm.taskType === 3) {
        //消息模板
        if (this.templateIdList.length === 0) {
          this.$message.error('请选择消息模板')
          return
        }
        data.messageId = JSON.stringify(this.templateIdList)
      } else if (this.addTaskForm.taskType === 4) {
        if (this.ticketIdList.length === 0) {
          this.$message.error('请选择优惠券')
          return
        }

        //优惠券发放
        data.ticketId = JSON.stringify(this.ticketIdList)
      } else if (this.addTaskForm.taskType === 5) {
        //公众号推文
        if (this.graphicList.length === 0) {
          this.$message.error('请选择公众号推文')
          return
        }
        data.articleId = JSON.stringify(this.graphicList)
      } else if (this.addTaskForm.taskType === 6) {
        data.feedbackType = Number(this.addTaskForm.feedbackType) //反馈方式
      }
      if (this.addTaskForm.guideType === 1) {
        data.guideType = Number(this.addTaskForm.guideType)
        data.dealerType = Number(this.addTaskForm.dealerType)
      } else if (this.addTaskForm.guideType === 2) {
        data.guideType = Number(this.addTaskForm.guideType)
        data.storeType = Number(this.addTaskForm.storeType)
      } else if (this.addTaskForm.guideType === 3) {
        data.guideType = Number(this.addTaskForm.guideType)
        if (this.custList.length === 0) {
          this.$message.error('请填写人群包')
          this.spinning = false
          return
        }
        data.custPack = JSON.stringify(this.custList)
      }
      if (this.addTaskForm.taskObject === 3) {
        if (this.custList.length === 0) {
          this.$message.error('请填写人群包')
          this.spinning = false
          return
        }
        data.custPack = JSON.stringify(this.custList)
      }
      if (!this.addTaskForm.expireType) {
        data.expireType = 0
      }

      console.log('addBtn    doing  ')
      console.log('editdata   ', data)
      addTask(data, res => {
        console.log(res, 'ressss')
        let vm = this
        taskDefineId = res.data
        console.log('taskDefineId   ' + taskDefineId)
        let code = res.code
        if (code === 200) {
          let data = {
            taskDefineId: this.$route.query.id,
            mediaContent: this.enclosure.mediaContent,
            mediaType: this.enclosure.mediaType,
            urlPic: this.enclosure.urlPic, //链接封面，小程序封面
            // url: imgList[0],//视频链接，网页链接
            urlTitle: this.enclosure.urlTitle, //链接标题，小程序标题
            url: this.enclosure.url
          }
          console.log('mmmdata', data)
          //添加附件
          uploadTaskMedia(data, res => {
            console.log(res)
            this.$message.success('保存成功')
            this.$router.back()
          })
        } else if (code === 500) {
          this.$message.error('请完善填写内容')
        } else {
          this.$message.error(res.msg)
        }
      })
    },

    // 选择执行时效
    changeexecType(val) {
      let execType = val
      this.cleanExecType()
      if (execType === 2) {
        this.onceVisible = true
      } else if (execType === 1) {
        this.circulationVisible = true
      } else if (execType === 3) {
        this.strikeVisible = true
      }
    },
    cleanExecType() {
      this.onceVisible = false
      this.circulationVisible = false
      this.strikeVisible = false
    },
    // 选择任务类型
    changetaskType(val) {
      this.addTaskForm.custConnectType = []
      this.addTaskForm.wechatType = ''
      this.rangeVisible = false
      this.addTaskForm.messageId = ''
      this.addTaskForm.ticketId = ''
      this.addTaskForm.articleId = ''
      let taskType = val
      this.cleantaskType()
      if (taskType === 1) {
        this.callVisible = true
        this.isDisabled = true //执行导购选择框不可用
        this.addTaskForm.guideType = 3 //执行导购默认选择指定会员
        this.appointvipGuideVisible = true //人群包输入框显示
        this.appointGuideVisible = false //指定导购选择范围框隐藏
        this.appointshopGuideVisible = false //指定门店选择范围框隐藏
        this.addTaskForm.feedbackType = null
        // \\\\
      } else if (taskType === 2) {
        this.wechatVisible = true
        this.isDisabled = false
        this.addTaskForm.feedbackType = null
      } else if (taskType === 3) {
        this.messIdVisible = true
        this.isDisabled = false
        this.addTaskForm.feedbackType = null
      } else if (taskType === 4) {
        this.onSaleVisible = true
        this.isDisabled = false
        this.addTaskForm.feedbackType = null
      } else if (taskType === 5) {
        this.officialAccountsVisible = true
        this.isDisabled = false
        this.addTaskForm.feedbackType = null
      } else if (taskType === 6) {
        this.outlineVisible = true
        this.isDisabled = false
        this.addTaskForm.feedbackType = null
        // this.appointvipGuideVisible = false
        // this.ifAuto = true
      } else if (taskType === 7) {
        //添加微信
        this.isDisabled = true //执行导购选择框不可用
        this.addTaskForm.guideType = 3 //执行导购默认选择指定会员
        this.appointvipGuideVisible = true //人群包输入框显示
        this.appointGuideVisible = false //指定导购选择范围框隐藏
        this.appointshopGuideVisible = false //指定门店选择范围框隐藏
        this.addTaskForm.feedbackType = null
      }
      if (taskType === 6) {
        this.ifAuto = true
      } else {
        this.ifAuto = false
      }
    },
    cleantaskType() {
      this.callVisible = false
      this.wechatVisible = false
      this.outlineVisible = false
      this.messIdVisible = false
      this.onSaleVisible = false
      this.officialAccountsVisible = false
    },
    // changetargetVip(val){
    //   if(val===1){
    //     this.appointvipGuideVisible = true
    //   }
    // },
    //朋友圈可见选择下拉框
    changeRange(val) {
      if (val === 1) {
        this.isDisabled = false //执行导购选择框可用
      } else if (val === 2) {
        this.isDisabled = true //执行导购选择框不可用
        this.addTaskForm.guideType = 3 //执行导购默认选择指定会员
        this.appointvipGuideVisible = true //人群包输入框显示
        this.appointGuideVisible = false //指定导购选择范围框隐藏
        this.appointshopGuideVisible = false //指定门店选择范围框隐藏
      }
    },
    //选择反馈方式
    changeFeedBack(val) {
      // this.cleanFeedBack()
      if (val === 0) {
        console.log(1)
        this.isDisabled = false //执行导购选择框可用
      } else if (val === 1) {
        this.isDisabled = true //执行导购选择框不可用
        this.addTaskForm.guideType = 3 //执行导购默认选择指定会员
        this.appointvipGuideVisible = true //人群包输入框显示
        this.appointGuideVisible = false //指定导购选择范围框隐藏
        this.appointshopGuideVisible = false //指定门店选择范围框隐藏
      }
    },
    cleanFeedBack() {
      console.log(1)
    },
    //选择执行导购
    changeGuide(val) {
      this.cleanGuide()
      if (val === 1) {
        //选择指定导购
        this.appointGuideVisible = true
        this.addTaskForm.storeType = null //清空门店选择范围
        this.shopExcel = false //门店excel上传按钮隐藏
        this.addTaskForm.custPack = '' //清空人群包ID输入框内容
        // this.vipList.length = 0 //清空额外添加人群包ID
      } else if (val === 2) {
        //选择指定门店
        this.appointshopGuideVisible = true
        this.addTaskForm.dealerType = null //清空导购选择范围
        this.guideExcel = false //指定导购excel上传按钮隐藏
        this.addTaskForm.custPack = '' //清空人群包ID输入框内容
        // this.vipList.length = 0 //清空额外添加人群包ID
      } else if (val === 3) {
        //选择指定会员
        this.appointvipGuideVisible = true
        this.addTaskForm.dealerType = null //清空导购选择范围
        this.guideExcel = false //指定导购excel上传按钮隐藏
        this.addTaskForm.storeType = null //清空门店选择范围
        this.shopExcel = false //门店excel上传按钮隐藏
      }
    },
    cleanGuide() {
      this.appointGuideVisible = false
      this.appointshopGuideVisible = false
      this.appointvipGuideVisible = false
    },
    scopeGuide(val) {
      console.log(val)
      if (val === 0) {
        this.guideExcel = false
      } else if (val === 1) {
        this.guideExcel = true
      }
    },
    scopeShop(val) {
      if (val === 0) {
        this.shopExcel = false
      } else if (val === 1) {
        this.shopExcel = true
      }
    },
    //选择执行周期
    changecycleType(val) {
      this.cleancycleType()
      if (val === 1) {
        this.daysVisible = true
      } else if (val === 2) {
        this.weeksVisible = true
      } else if (val === 3) {
        this.monthsVisible = true
      }
    },
    cleancycleType() {
      this.daysVisible = false
      this.weeksVisible = false
      this.monthsVisible = false
    },
    //选择要提交的附件
    changemediaType(val) {
      this.cleanmediaType()
      if (val.key === 1) {
        this.textVisible = true
      } else if (val.key === 2) {
        this.imgVisible = true
      } else if (val.key === 3) {
        this.movieVisible = true
      } else if (val.key === 4) {
        this.linkVisible = true
      } else if (val.key === 5) {
        this.programVisible = true
      }
    },
    cleanmediaType() {
      this.linkVisible = false
      this.imgVisible = false
      this.movieVisible = false
      this.programVisible = false
      this.textVisible = false
    },
    async uploadChange(e) {
      let file = e.file.originFileObj
      let _this = this
      _this.spinning = true
      if (e.file.status === 'done') {
        //检测文件类型
        if (!_this.checkFileType(file)) {
          _this.$message.warning('抱歉,请选择excel文件!')
          _this.spinning = false
          _this.fileList = []
          return
        }
        //上传成功
        _this.spinning = false
      } else if (e.file.status === 'removed') {
        _this.spinning = false
        _this.fileList = []
      } else if (e.file.status === 'error') {
        _this.$message.error('上传失败,请稍后再试!')
        _this.fileList = []
        _this.spinning = false
        return
      }
    },
    // 校验文件格式
    checkFileType(file) {
      let _this = this
      let flog = false
      let allowed = ['.xlsx', '.xls']
      //得到上传文件的值
      let fileName = file.name
      //取其类型
      let fileType = fileName.lastIndexOf('.')
      //返回位于String对象中指定位置的子字符串并转换为小写.
      let extension = fileName.substring(fileType).toLowerCase().replace('.', '')
      //判断允许上传的文件格式
      if (allowed.includes(extension)) {
        flog = true
      } else {
        flog = false
      }
      return flog
    },
    beforeUpload(file) {
      console.log(file)
      this.fileList = [file]
      return false
    },
    async handleUpload(id, file, url) {
      console.log(file)
      console.log(id)
      console.log(url)
      let formData = new FormData()
      let config = {
        headers: { 'Content-Type': 'multipart/form-data' }
      }
      formData.append('file', file)
      formData.append('taskDefineId', id)
      // importStoreExcel
      let data = await axios.post(api.uploadExecl + url, formData, config).then(res => {
        return res
      })
      console.log(data)
      this.spinning = false
    },
    isSize(file, width, height) {
      return new Promise((resolve, reject) => {
        let _URL = window.URL || window.webkitURL
        let img = new Image()
        img.src = _URL.createObjectURL(file)
        img.onload = function () {
          console.log(img.width, img.height, 'widheoi')
          if (img.width < width && img.height < height) {
            resolve(true)
          } else {
            resolve(false)
          }
        }
      })
    },
    // 附件
    beforeUploadImg(file) {
      return new Promise((resolve, reject) => {
        let _this = this
        const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png'
        const isLt5M = file.size / 1024 / 1024 < 10
        if (!isJpgOrPng) {
          _this.$message.error('只能上传png或jpg格式的图片!')
          // _this.handelRemove(file)
          return isJpgOrPng
        }
        if (!isLt5M) {
          // _this.affixFileList = []
          _this.$message.error('图片尺寸不能超过 10MB!')
          return isLt5M
        }
        _this.isSize(file, 1440, 1080).then(res => {
          console.log(res)
          if (!res) {
            // _this.affixFileList = []
            _this.$message.error('图片格式不能超过1440x1080!')
            return res
          } else {
            return resolve(true)
          }
        })
      })
    },
    //预览图片
    async handlePreviewImg(file) {
      if (!file.url && !file.preview) {
        file.preview = await getBase64(file.originFileObj)
      }
      this.previewImage = file.url || file.preview
      this.previewVisible = true
    },
    //上传文件改变时
    handleChangeImg(data) {
      let fileList = [...data.fileList]
      this.affixFileList = fileList
      if (data.file.status === 'done') {
        this.$message.success('上传成功!')
      }
      if (data.file.status === 'error') {
        this.$message.error('上传失败!')
      }
    },
    // 添加图片
    handleCancelImg() {
      this.previewVisible = false
    },
    // 移出图片
    handelRemove(file) {
      this.affixFileList.forEach((item, index) => {
        if (item.uid == file.uid) {
          this.affixFileList.splice(index, 1)
        }
      })
    },
    openFile(file) {
      console.log(file)
    },
    //视频的上传事件
    handleChangeVideo(data) {
      console.log(data)
      let fileList = [...data.fileList]
      // console.log(data.file)
      // let url = URL.createObjectURL(data.file.originFileObj);
      // console.log(url)
      // let audioElement = new Audio(url);
      // audioElement.addEventListener("loadedmetadata", function() {
      //   console.log(audioElement.duration);
      //   this.videoTime = audioElement.duration
      //   console.log(this.videoTime);
      // });
      this.affixFileList = fileList
      if (data.file.status === 'done') {
        this.$message.success('上传成功!')
      }
      if (data.file.status === 'error') {
        this.$message.error('上传失败!')
      }
    },
    isVideoTime(data, time) {
      return new Promise((resolve, reject) => {
        let url = URL.createObjectURL(data.file.originFileObj)
        console.log(url)
        let audioElement = new Audio(url)
        audioElement.addEventListener('loadedmetadata', function () {
          console.log(audioElement.duration)
          this.videoTime = audioElement.duration
          console.log(this.videoTime)
          if (this.videoTime < time) {
            resolve(true)
          } else {
            resolve(false)
          }
        })
      })
    },
    // 上传视频
    videoBeforeUpload(file) {
      this.affixFileList = []
      console.log(file)
      return new Promise((resolve, reject) => {
        const isJpgOrPng = file.type === 'video/mp4'
        const isLt10M = file.size / 1024 / 1024 < 10
        if (!isJpgOrPng) {
          this.$message.error('只能上传mp4格式的视频!')
          // this.affixFileList = []
          return isJpgOrPng
          // return reject(false)
        } else if (!isLt10M) {
          // this.affixFileList = []
          this.$message.error('视频大小不能超过10M!')
          return isLt10M
          // return reject(false)
        } else {
          return resolve(true)
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
.titleMess {
  font-size: 18px;
}
.ant-divider {
  margin: 15px 0;
}
.ant-form {
  .ant-select {
    width: 170px;
    margin-right: 10px;
  }
  .ant-input {
    width: 200px;
  }
  .ant-upload-list {
    width: 200px;
  }
}
.addBtn {
  margin-top: 20px;
}
.tishi {
  margin-left: 5px;
  font-size: 12px;
  color: #7f7f7f;
}
.ant-form-item {
  display: flex;
}
.add_btn,
.del_btn {
  padding: 0 10px;
  cursor: pointer;
  margin-left: 10px;
}
.getId {
  font-size: 12px;
  margin-left: 10px;
}
.ml {
  margin-left: 15px;
}
</style>
